/*
 * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

/*
 * @(#)DBMetaClient5.java	1.17 02/01/12
 */

package jdbcts.dbMeta.dbMeta5;

import java.io.*;
import java.util.*;

import java.sql.*;
import javax.sql.*;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import com.sun.cts.util.*;
import com.sun.cts.porting.*;
import com.sun.cts.harness.*;

import java.rmi.RemoteException;

import javasoft.sqe.javatest.Status;
import jdbcts.SuperTest;
import jdbcts.common.DataSourceConnection;
import jdbcts.common.DriverManagerConnection;
import jdbcts.common.dbSchema;

import com.sun.cts.tests.jdbc.ee.common.*;

// Merant DataSource class
//import com.merant.sequelink.jdbcx.datasource.*;

/**
 * The DBMetaClient5 class tests methods of DatabaseMetaData interface using
 * Sun's J2EE Reference Implementation.
 * 
 * @author
 * @version 1.7, 06/16/99
 */

public class DBMetaClient5 extends SuperTest implements Serializable
{
    private static final String testName = "jdbc.ee.dbMeta.dbMeta5";

    // Naming specific member variables
    private CTSNamingContextInterface jc = null;

    // Harness requirements

    private transient static Connection conn = null;

    private transient static DatabaseMetaData dbmd = null;

    private DataSource ds1 = null;

    private static dbSchema dbSch = null;

    // private String dbName=null,dbUser=null,drManager=null;
    private static String drManager = null;

    // private String
    // sCatalogName=null,sSchemaName=null,sPtable=null,sFtable=null;

    /* Run test in standalone mode */
    // public static void main(String[] args)
    // {
    // DBMetaClient5 theTests = new DBMetaClient5();
    // Status s=theTests.run(args, System.out, System.err);
    // s.exit();
    // }
    /* Test setup: */
    /*
     * @class.setup_props: Driver, the Driver name; db1, the database name with
     * url; user1, the database user name; password1, the database password;
     * db2, the database name with url; user2, the database user name;
     * password2, the database password; DriverManager, flag for DriverManager;
     * ptable, the primary table; ftable, the foreign table; cofSize, the
     * initial size of the ptable; cofTypeSize, the initial size of the ftable;
     * binarySize, size of binary data type; varbinarySize, size of varbinary
     * data type; longvarbinarySize, size of longvarbinary data type;
     * 
     * @class.testArgs: -ap ctssql.stmt
     */

    // public void setup(String[] args, Properties p) throws Exception
    @BeforeClass
    public static void setup() throws Exception
    {
	try
	{
	    try
	    {
		// drManager = p.getProperty("DriverManager","");
		drManager = isDRManager;
		// dbName = p.getProperty("db1","");
		// dbUser = p.getProperty("user1","");
		// sPtable = p.getProperty("ptable","CTSTABLE1");
		// sFtable = p.getProperty("ftable","CTSTABLE2");
		// if (dbName.length() == 0)
		// throw new Exception("Invalid db1  Database Name");
		// if (dbUser.length() == 0)
		// throw new Exception("Invalid Login Id");
		// if (sPtable.length() == 0)
		// throw new Exception("Invalid Primary table");
		// if (sFtable.length() == 0)
		// throw new Exception("Invalid Foreign table");
		if (drManager.length() == 0)
		    throw new Exception("Invalid DriverManager Name");

		// int nLocdbname = dbName.indexOf('=');
		// sCatalogName = dbName.substring(nLocdbname +1);
		// sCatalogName = sCatalogName.trim();
		// sSchemaName = dbUser;

		if (drManager.equals("yes"))
		{
		    logMsg("Using DriverManager");
		    DriverManagerConnection dmCon = new DriverManagerConnection();
		    // conn = dmCon.getConnection(p);
		    conn = dmCon.getConnection(null);
		}
		else
		{
		    logMsg("Using DataSource");
		    DataSourceConnection dsCon = new DataSourceConnection();
		    // conn = dsCon.getConnection(p);
		    conn = dsCon.getConnection(null);
		}
		dbSch = new dbSchema();
		// dbSch.createData(p,conn);
		dbmd = conn.getMetaData();
	    }
	    catch (SQLException ex)
	    {
		logErr("SQL Exception : " + ex.getMessage());
	    }
	}
	catch (Exception e)
	{
	    logErr("Setup Failed!");
	    TestUtil.printStackTrace(e);
	}
    }

    /*
     * @testName: testSupportsGroupByUnrelated
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsGroupByUnrelated() method must return a boolean value; true if a
     * GROUP BY clause can use columns that are not in the SELECT clause and
     * false otherwise (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the supportsGroupByUnrelated() method on that
     * object. It should return a boolean value; either true or false.
     */
    @Test
    public void testSupportsGroupByUnrelated() throws Exception
    {
	try
	{
	    // invoke on the supportsGroupByUnrelated
	    logMsg("Calling supportsGroupByUnrelated on DatabaseMetaData");
	    boolean retValue = dbmd.supportsGroupByUnrelated();
	    if (retValue)
	    {
		logMsg("supportsGroupByUnrelated method is supported");
	    }
	    else
	    {
		logMsg("supportsGroupByUnrelated method is not supported");
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception("Call to supportsGroupByUnrelated is Failed!",
		    sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception("Call to supportsGroupByUnrelated is Failed!",
		    e);
	}
    }

    /*
     * @testName: testSupportsGroupByBeyondSelect
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsGroupByBeyondSelect() method must return a boolean value; true if
     * a GROUP BY clause can use columns that are not in the SELECT clause. (See
     * JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the supportsGroupByBeyondSelect() method on that
     * object. It should return a boolean value; either true or false.
     */
    @Test
    public void testSupportsGroupByBeyondSelect() throws Exception
    {
	try
	{
	    // invoke on the supportsGroupByBeyondSelect
	    logMsg("Calling supportsGroupByBeyondSelect on DatabaseMetaData");
	    boolean retValue = dbmd.supportsGroupByBeyondSelect();
	    if (retValue)
	    {
		logMsg("supportsGroupByBeyondSelect method is supported");
	    }
	    else
	    {
		logMsg("supportsGroupByBeyondSelect method is not supported");
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception(
		    "Call to supportsGroupByBeyondSelect is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception(
		    "Call to supportsGroupByBeyondSelect is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsLikeEscapeClause
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsLikeEscapeClause() method must return a boolean value true if the
     * database supports specifying a LIKE escape clause and false otherwise. A
     * JDBC compliant driver always return true. (See JDK 1.2.2 API
     * documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the supportsLikeEscapeClause() method on that
     * object. It should return a boolean value; either true or false.
     */
    @Test
    public void testSupportsLikeEscapeClause() throws Exception
    {
	try
	{
	    // invoke on the supportsLikeEscapeClause
	    logMsg("Calling supportsLikeEscapeClause on DatabaseMetaData");
	    boolean retValue = dbmd.supportsLikeEscapeClause();
	    if (retValue)
	    {
		logMsg("supportsLikeEscapeClause method is supported");
	    }
	    else
	    {
		logMsg("supportsLikeEscapeClause method is not supported");
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception("Call to supportsLikeEscapeClause is Failed!",
		    sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception("Call to supportsLikeEscapeClause Failed!", e);
	}
    }

    /*
     * @testName: testSupportsMultipleResultSets
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsMultipleResultSets() method must return a boolean value true if
     * the database supports multiple result sets from a single execute
     * statement and false otherwise. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the supportsMultipleResultSets() method on that
     * object. It should return a boolean value; either true or false.
     */
    @Test
    public void testSupportsMultipleResultSets() throws Exception
    {
	try
	{
	    // invoke on the supportsMultipleResultSets
	    logMsg("Calling supportsMultipleResultSets on DatabaseMetaData");
	    boolean retValue = dbmd.supportsMultipleResultSets();
	    if (retValue)
	    {
		logMsg("supportsMultipleResultSets method is supported");
	    }
	    else
	    {
		logMsg("supportsMultipleResultSets method is not supported");
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception(
		    "Call to supportsMultipleResultSets is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception(
		    "Call to supportsMultipleResultSets is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsMultipleTransactions
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsMultipleTransactions() method must return a boolean value; true
     * if multiple transactions can be open at once on different connections and
     * false otherwise. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the supportsMultipleTransactions() method on that
     * object. It should return a boolean value; either true or false.
     */
    @Test
    public void testSupportsMultipleTransactions() throws Exception
    {
	try
	{
	    // invoke on the supportsMultipleTransactions
	    logMsg("Calling supportsMultipleTransactions on DatabaseMetaData");
	    boolean retValue = dbmd.supportsMultipleTransactions();
	    if (retValue)
	    {
		logMsg("supportsMultipleTransactions method is supported");
	    }
	    else
	    {
		logMsg("supportsMultipleTransactions method is not supported");
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception(
		    "Call to supportsMultipleTransactions is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception("Call to supportsMultipleTransactions Failed!",
		    e);
	}
    }

    /*
     * @testName: testSupportsNonNullableColumns
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsNonNullableColumns() method must return a boolean value; true if
     * the database supports defining columns as non-nullable and false
     * otherwise. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the supportsNonNullableColumns() method on that
     * object. It should return a boolean value; either true or false.
     */
    @Test
    public void testSupportsNonNullableColumns() throws Exception
    {
	try
	{
	    // invoke on the supportsNonNullableColumns
	    logMsg("Calling supportsNonNullableColumns on DatabaseMetaData");
	    boolean retValue = dbmd.supportsNonNullableColumns();
	    if (retValue)
	    {
		logMsg("supportsNonNullableColumns method is supported");
	    }
	    else
	    {
		logMsg("supportsNonNullableColumns method is not supported");
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception(
		    "Call to supportsNonNullableColumns is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception(
		    "Call to supportsNonNullableColumns is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsMinimumSQLGrammar
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsMinimumSQLGrammar() method must return a boolean value; true if
     * the database supports the ODBC Minimum SQL grammar and false otherwise.
     * All JDBC Compliant drivers must return true. (See JDK 1.2.2 API
     * documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the supportsMinimumSQLGrammar() method on that
     * object. It should return a boolean value; either true or false.
     */
    @Test
    public void testSupportsMinimumSQLGrammar() throws Exception
    {
	try
	{
	    // invoke on the supportsMinimumSQLGrammar
	    logMsg("Calling supportsMinimumSQLGrammar on DatabaseMetaData");
	    boolean retValue = dbmd.supportsMinimumSQLGrammar();
	    if (retValue)
	    {
		logMsg("supportsMinimumSQLGrammar method is supported");
	    }
	    else
	    {
		logMsg("supportsMinimumSQLGrammar method is not supported");
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception("Call to supportsMinimumSQLGrammar is Failed!",
		    sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception("Call to supportsMinimumSQLGrammar Failed!", e);
	}
    }

    /*
     * @testName: testSupportsCoreSQLGrammar
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsCoreSQLGrammar() method must return a boolean value true if the
     * database supports the ODBC core SQL grammar and false otherwise. (See JDK
     * 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the supportsCoreSQLGrammar() method on that object.
     * It should return a boolean value; either true or false.
     */
    @Test
    public void testSupportsCoreSQLGrammar() throws Exception
    {
	try
	{
	    // invoke on the supportsCoreSQLGrammar
	    logMsg("Calling supportsCoreSQLGrammar on DatabaseMetaData");
	    boolean retValue = dbmd.supportsCoreSQLGrammar();
	    if (retValue)
	    {
		logMsg("supportsCoreSQLGrammar method is supported");
	    }
	    else
	    {
		logMsg("supportsCoreSQLGrammar method is not supported");
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception("Call to supportsCoreSQLGrammar is Failed!",
		    sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception("Call to supportsCoreSQLGrammar is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsExtendedSQLGrammar
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsExtendedSQLGrammar() method must return a boolean value; true if
     * the database supports the ODBC Extended SQL grammar and false otherwise.
     * (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the supportsExtendedSQLGrammar() method on that
     * object. It should return a boolean value; either true or false.
     */
    @Test
    public void testSupportsExtendedSQLGrammar() throws Exception
    {
	try
	{
	    // invoke on the supportsExtendedSQLGrammar
	    logMsg("Calling supportsExtendedSQLGrammar on DatabaseMetaData");
	    boolean retValue = dbmd.supportsExtendedSQLGrammar();
	    if (retValue)
	    {
		logMsg("supportsExtendedSQLGrammar method is supported");
	    }
	    else
	    {
		logMsg("supportsExtendedSQLGrammar method is not supported");
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception(
		    "Call to supportsExtendedSQLGrammar is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception(
		    "Call to supportsExtendedSQLGrammar is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsANSI92EntryLevelSQL
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsANSI92EntryLevelSQL() method must return a boolean value; true if
     * the database supports ANSI92 entry level SQL grammar and false otherwise.
     * All JDBC Compliant drivers must return true. (See JDK 1.2.2 API
     * documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the supportsANSI92EntryLevelSQL() method on that
     * object. It should return a boolean value; either true or false.
     */
    @Test
    public void testSupportsANSI92EntryLevelSQL() throws Exception
    {
	try
	{
	    // invoke on the supportsANSI92EntryLevelSQL
	    logMsg("Calling supportsANSI92EntryLevelSQL on DatabaseMetaData");
	    boolean retValue = dbmd.supportsANSI92EntryLevelSQL();
	    if (retValue)
	    {
		logMsg("supportsANSI92EntryLevelSQL method is supported");
	    }
	    else
	    {
		logMsg("supportsANSI92EntryLevelSQL method is not supported");
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception(
		    "Call to supportsANSI92EntryLevelSQL is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception(
		    "Call to supportsANSI92EntryLevelSQL is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsANSI92IntermediateSQL
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsANSI92IntermediateSQL() method must return a boolean value; true
     * if the database supports ANSI92 Intermediate SQL grammar and false
     * otherwise.(See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the supportsANSI92IntermediateSQL() method on that
     * object. It should return a boolean value; either true or false.
     */
    @Test
    public void testSupportsANSI92IntermediateSQL() throws Exception
    {
	try
	{
	    // invoke on the supportsANSI92IntermediateSQL
	    logMsg("Calling supportsANSI92IntermediateSQL on DatabaseMetaData");
	    boolean retValue = dbmd.supportsANSI92IntermediateSQL();
	    if (retValue)
	    {
		logMsg("supportsANSI92IntermediateSQL method is supported");
	    }
	    else
	    {
		logMsg("supportsANSI92IntermediateSQL method is not supported");
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception(
		    "Call to supportsANSI92IntermediateSQL is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception(
		    "Call to supportsANSI92IntermediateSQL is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsANSI92FullSQL
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The supportsANSI92FullSQL()
     * method must return a boolean value true if the database supports ANSI92
     * Full SQL grammar and false otherwise. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the supportsANSI92FullSQL() method on that object.
     * It should return a boolean value; either true or false.
     */
    @Test
    public void testSupportsANSI92FullSQL() throws Exception
    {
	try
	{
	    // invoke on the supportsANSI92FullSQL
	    boolean retValue = dbmd.supportsANSI92FullSQL();
	    logMsg("Calling supportsANSI92FullSQL on DatabaseMetaData");
	    if (retValue)
	    {
		logMsg("supportsANSI92FullSQL method is supported");
	    }
	    else
	    {
		logMsg("supportsANSI92FullSQL method is not supported");
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception("Call to supportsANSI92FullSQL is Failed!",
		    sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception("Call to supportsANSI92FullSQL is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsIntegrityEnhancementFacility
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsIntegrityEnhancementFacility() method must return a boolean
     * value; true if the database supports the SQL Integrity Enhancement
     * Facility and false otherwise. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the supportsIntegrityEnhancementFacility() method
     * onn that object. It should return a boolean value; either true or false.
     */
    @Test
    public void testSupportsIntegrityEnhancementFacility() throws Exception
    {
	try
	{
	    // invoke on the supportsIntegrityEnhancementFacility
	    logMsg("Calling supportsIntegrityEnhancementFacility on DatabaseMetaData");
	    boolean retValue = dbmd.supportsIntegrityEnhancementFacility();
	    if (retValue)
	    {
		logMsg("supportsIntegrityEnhancementFacility method is supported");
	    }
	    else
	    {
		logMsg("supportsIntegrityEnhancementFacility method is not supported");
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception(
		    "Call to supportsIntegrityEnhancementFacility is Failed!",
		    sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception(
		    "Call to supportsIntegrityEnhancementFacility is Failed!",
		    e);
	}
    }

    /*
     * @testName: testSupportsOuterJoins
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The supportsOuterJoins()
     * method must return a boolean value; true if the database supports form of
     * outer joins and false otherwise. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the supportsOuterJoins() method on that object. It
     * should return a boolean value; either true or false.
     */
    @Test
    public void testSupportsOuterJoins() throws Exception
    {
	try
	{
	    // invoke on the supportsOuterJoins
	    logMsg("Calling supportsOuterJoins on DatabaseMetaData");
	    boolean retValue = dbmd.supportsOuterJoins();
	    if (retValue)
	    {
		logMsg("supportsOuterJoins method is supported");
	    }
	    else
	    {
		logMsg("supportsOuterJoins method is not supported");
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception("Call to supportsOuterJoins is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception("Call to supportsOuterJoins is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsFullOuterJoins
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsFullOuterJoins() method must return a boolean value; true if the
     * database supports full nested outer joins and false otherwise. (See JDK
     * 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the supportsFullOuterJoins() method on that object.
     * It should return a boolean value; either true or false.
     */
    @Test
    public void testSupportsFullOuterJoins() throws Exception
    {
	try
	{
	    // invoke on the supportsFullOuterJoins
	    logMsg("Calling supportsFullOuterJoins on DatabaseMetaData");
	    boolean retValue = dbmd.supportsFullOuterJoins();
	    if (retValue)
	    {
		logMsg("supportsFullOuterJoins method is supported");
		if (!dbmd.supportsLimitedOuterJoins())
		{

		    // Must be true if supportsFullOuterJoins()
		    // is true;

		    throw new Exception("supportsLimitedOuterJoins() must "
			    + "be true if supportsFullOuterJoins() "
			    + "is true!");
		}
	    }
	    else
	    {
		logMsg("supportsFullOuterJoins method is not supported");
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception("Call to supportsFullOuterJoins is Failed!",
		    sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception("Call to supportsFullOuterJoins is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsLimitedOuterJoins
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsLimitedOuterJoins() method must return a boolean value; true if
     * the database supports limited outer joins and false otherwise. Note if
     * the method supportsFullOuterJoins return true, this method will return
     * true. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the supportsLimitedOuterJoins() method on that
     * object. It should return a boolean value; either true or false.
     */
    @Test
    public void testSupportsLimitedOuterJoins() throws Exception
    {
	try
	{
	    // invoke on the supportsLimitedOuterJoins
	    logMsg("Calling supportsLimitedOuterJoins on DatabaseMetaData");
	    boolean retValue = dbmd.supportsLimitedOuterJoins();
	    if (retValue)
	    {
		logMsg("supportsLimitedOuterJoins method is supported");
	    }
	    else
	    {
		logMsg("supportsLimitedOuterJoins method is not supported");
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception("Call to supportsLimitedOuterJoins is Failed!",
		    sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception("Call to supportsLimitedOuterJoins is Failed!",
		    e);
	}
    }

    /*
     * @testName: testGetSchemaTerm
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The getSchemaTerm() method
     * must return a String object representing the vendor term for "schema".
     * (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the getSchemaTerm() method on that object. It
     * should return a String and NULL if it cannot be generated.
     */
    @Test
    public void testGetSchemaTerm() throws Exception
    {
	try
	{
	    // invoke on the getSchemaTerm
	    logMsg("Calling getSchemaTerm on DatabaseMetaData");
	    String sRetValue = dbmd.getSchemaTerm();
	    if (sRetValue == null)
	    {
		logMsg("getSchemaTerm method does not returns the vendor's preferred term for schema ");
	    }
	    else
	    {
		logMsg("getSchemaTerm method returns:  " + sRetValue);
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception("Call to getSchemaTerm is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception("Call to getSchemaTerm Failed!", e);
	}
    }

    /*
     * @testName: testGetProcedureTerm
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The getProcedureTerm()
     * method must return a String object containing the vendor term for
     * "procedure". (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the getProcedureTerm() method on that object. It
     * should return a String and NULL if it cannot be generated.;
     */
    @Test
    public void testGetProcedureTerm() throws Exception
    {
	try
	{
	    // invoke on the getProcedureTerm
	    logMsg("Calling getProcedureTerm on DatabaseMetaData");
	    String sRetValue = dbmd.getProcedureTerm();
	    if (sRetValue == null)
	    {
		logMsg("getProcedureTerm method does not returns the vendor's preferred term for procedure ");
	    }
	    else
	    {
		logMsg("getProcedureTerm method returns:  " + sRetValue);
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception("Call to getProcedureTerm is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception("Call to getProcedureTerm is Failed!", e);
	}
    }

    /*
     * @testName: testGetCatalogTerm
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The getCatalogTerm() method
     * must return a String object containing the vendor term for "catalog".
     * (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the getCatalogTerm() method on that object. It
     * should return a String and NULL if it cannot be returned.
     */
    @Test
    public void testGetCatalogTerm() throws Exception
    {
	try
	{
	    // invoke on the getCatalogTerm
	    logMsg("Calling getCatalogTerm on DatabaseMetaData");
	    String sRetValue = dbmd.getCatalogTerm();
	    if (sRetValue == null)
	    {
		logMsg("getCatalogTerm method does not returns the vendor's preferred term for catalog ");
	    }
	    else
	    {
		logMsg("getCatalogTerm method returns:  " + sRetValue);
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception("Call to getCatalogTerm is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception("Call to getCatalogTerm is Failed!", e);
	}
    }

    /*
     * @testName: testIsCatalogAtStart
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The isCatalogAtStart()
     * method must return a boolean value; true if the catalog name appears at
     * the start of a fully qualified table name; false if it appears at the
     * end. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase and call the isCatalogAtStart() method on that object. It
     * should return a boolean value; either true or false.
     */
    @Test
    public void testIsCatalogAtStart() throws Exception
    {
	try
	{
	    // invoke on the isCatalogAtStart
	    logMsg("Calling isCatalogAtStart on DatabaseMetaData");
	    boolean retValue = dbmd.isCatalogAtStart();
	    if (retValue)
	    {
		logMsg("isCatalogAtStart metohd returns catalog appear at the start");
	    }
	    else
	    {
		logMsg("isCatalogAtStart metohd returns catalog appear at the end");
	    }
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception("Call to isCatalogAtStart is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception("Call to isCatalogAtStart is Failed!", e);
	}
    }

    /* cleanup */
    @AfterClass
    public static void cleanup() throws Exception
    {
	try
	{
	    // Close the database
	    // dbSch.destroyData(conn);
	    dbSch.dbUnConnect(conn);
	    logMsg("Cleanup ok;");
	}
	catch (Exception e)
	{
	    logErr("An error occurred while closing the database connection");
	}
    }
}
